package com.bifrost.model.sap;

import com.bifrost.entity.Order;
import com.bifrost.entity.OrderReturn;
import com.bifrost.entity.TransactionSendLog;
import jdk.nashorn.internal.objects.annotations.Getter;
import jdk.nashorn.internal.objects.annotations.Setter;

import java.math.BigDecimal;
import java.util.Date;

/**
 * Author by yanxiaobo
 * Date on 2018/5/23$.
 */
public class Report {
    public static final String ZSJLY_WECHAT_MALL_WECHAT_PAY = "1";
    public static final String ZSYFS_WECHAT_MALL_WECHAT_PAY = "27";

    private String DATUM = new Long(new Date().getTime()).toString();//当前日期
    private String WERKS;//地点
    private Integer ZHXMH = 1;//行项目号
    private String ZSJLY = ZSJLY_WECHAT_MALL_WECHAT_PAY;//数据来源
    private String ZSYFS = ZSYFS_WECHAT_MALL_WECHAT_PAY;//收银方式
    private String ZZSYY;//收银员
    private String KUNNR;//客户编号
    private BigDecimal ZYS;//应收
    private BigDecimal ZYJ;//应缴
    private BigDecimal ZSJ;//实缴
    private String ZCJRQ;//创建日期

    public Report() {

    }

    public <T> Report(T o, TransactionSendLog log) {
        this.WERKS = log.getStroeCode();
        this.ZCJRQ = new Long(log.getCreateDate().getTime()).toString();
        if(!(o instanceof Order || o instanceof OrderReturn))
            throw new IllegalArgumentException("参数：" + o + " 类型错误，期望的类型是Order或者OrderReturn");
        if(log.getType() == TransactionSendLog.Type.SALES) {
            Order order = (Order) o;
            this.ZYS = order.getOrderTotal();
            this.ZYJ = order.getOrderTotal();
            this.ZSJ = order.getOrderTotal();
        } else {
            BigDecimal var = null;
            if(log.getType() == TransactionSendLog.Type.REFUND) {
                OrderReturn orderReturn = (OrderReturn)o;
                var = orderReturn.getRefundTotal();
            } else {
                Order cancel = (Order)o;
                var = cancel.getOrderTotal();
            }
            var = new BigDecimal("0").subtract(var);
            this.ZYS = var;
            this.ZYJ = var;
            this.ZSJ = var;

        }
    }


    public String getDATUM() {
        return DATUM;
    }

    public void setDATUM(String DATUM) {
        this.DATUM = DATUM;
    }

    public String getWERKS() {
        return WERKS;
    }

    public void setWERKS(String WERKS) {
        this.WERKS = WERKS;
    }

    public Integer getZHXMH() {
        return ZHXMH;
    }

    public void setZHXMH(Integer ZHXMH) {
        this.ZHXMH = ZHXMH;
    }

    public String getZSJLY() {
        return ZSJLY;
    }

    public void setZSJLY(String ZSJLY) {
        this.ZSJLY = ZSJLY;
    }

    public String getZSYFS() {
        return ZSYFS;
    }

    public void setZSYFS(String ZSYFS) {
        this.ZSYFS = ZSYFS;
    }

    public String getZZSYY() {
        return ZZSYY;
    }

    public void setZZSYY(String ZZSYY) {
        this.ZZSYY = ZZSYY;
    }

    public String getKUNNR() {
        return KUNNR;
    }

    public void setKUNNR(String KUNNR) {
        this.KUNNR = KUNNR;
    }

    public BigDecimal getZYS() {
        return ZYS;
    }

    public void setZYS(BigDecimal ZYS) {
        this.ZYS = ZYS;
    }

    public BigDecimal getZYJ() {
        return ZYJ;
    }

    public void setZYJ(BigDecimal ZYJ) {
        this.ZYJ = ZYJ;
    }

    public BigDecimal getZSJ() {
        return ZSJ;
    }

    public void setZSJ(BigDecimal ZSJ) {
        this.ZSJ = ZSJ;
    }

    public String getZCJRQ() {
        return ZCJRQ;
    }

    public void setZCJRQ(String ZCJRQ) {
        this.ZCJRQ = ZCJRQ;
    }
}
